<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <!-- INTERFACE -->
    <cc:interface >
         <cc:attribute name="bill" />   
         
    </cc:interface>

    <!-- IMPLEMENTATION -->
    <cc:implementation>
        <p:dataTable   value="#{cc.attrs.bill.bills}" var="b" rendered="#{cc.attrs.bill.bills.size()!=0}" sortBy="#{b.billType}"  >
            <f:facet name="header">  
                <h:outputLabel value="Opd Bills "/>
            </f:facet> 


            <p:column headerText="Time"  >
                <f:facet name="header">  
                    <h:outputLabel value="Time"/>
                </f:facet> 

                <h:outputLabel value="#{b.createdAt}" >
                    <f:convertDateTime pattern="h:mm a"/>
                </h:outputLabel>
            </p:column>


            <p:column headerText="Id" >
                <f:facet name="header">  
                    <h:outputLabel value="Id"/>
                </f:facet> 

                <h:outputLabel value="#{b.insId}"/>
            </p:column>

            <p:column headerText="To Department"  >
                <f:facet name="header">  
                    <h:outputLabel value="To Department"/>
                </f:facet> 

                <h:outputLabel value="#{b.toDepartment.name}"/>

            </p:column>

            <p:column headerText="Patient Name" >
                <f:facet name="header">  
                    <h:outputLabel value="Patient Name"/>
                </f:facet> 

                <h:outputLabel value=" #{b.patient.person.nameWithTitle}"/>               
            </p:column>
            <p:column headerText="Dis." style=" text-align: right">
                <f:facet name="header">  
                    <h:outputLabel value="Dis."/>
                </f:facet> 

                <h:outputLabel value="#{b.discount}">
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
            </p:column>
            <p:column headerText="Cash" style=" text-align: right"  >
                <f:facet name="header">  
                    <h:outputLabel value="Cash"/>
                </f:facet> 

                <h:outputLabel rendered="#{b.paymentMethod=='Cash'}" value="#{b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Cash'}" value="0.00" />
            </p:column>
            <p:column headerText="Credit" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="Credit"/>
                </f:facet> 

                <h:outputLabel rendered="#{b.paymentMethod=='Credit'}" value="#{b.netTotal}"  >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Credit'}" value="0.00"/>

            </p:column>
            <p:column headerText="C Card" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="C Card"/>
                </f:facet> 

                <h:outputLabel rendered="#{b.paymentMethod=='Card'}" value="#{b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Card'}" value="0.00"/>
            </p:column>
            <p:column headerText="Checque" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="Checque"/>
                </f:facet> 

                <h:outputLabel rendered="#{b.paymentMethod=='Cheque'}" value="#{b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Cheque'}" value="0.00"/>
            </p:column>
            <p:column headerText="Slip" style=" text-align: right" >
                <f:facet name="header">  
                    <h:outputLabel value="Slip"/>
                </f:facet> 

                <h:outputLabel rendered="#{b.paymentMethod=='Slip'}" value="#{b.netTotal}" >
                    <f:convertNumber pattern="#,##0.00"/>
                </h:outputLabel>
                <h:outputLabel rendered="#{b.paymentMethod!='Slip'}" value="0.00"/>
            </p:column>
            <p:column headerText="Remark" >
                <f:facet name="header">  
                    <h:outputLabel value="Remark"/>
                </f:facet> 

                <h:outputLabel value="Cancelled. (#{b.cancelledBill.insId})" rendered="#{b.cancelled==true}" ></h:outputLabel>
            </p:column>

            <p:summaryRow  >
                <p:column colspan="5">
                    Total:
                </p:column>               
                <p:column style=" text-align: right">
                    <h:outputLabel value="#{cc.attrs.bill.cash}" >
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>
                </p:column>
                <p:column style=" text-align: right" >
                    <h:outputLabel value="#{cc.attrs.bill.credit}">
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>

                </p:column>
                <p:column style=" text-align: right">
                    <h:outputLabel value="#{cc.attrs.bill.card}">
                        <f:convertNumber pattern="#,##0.00" />

                    </h:outputLabel>
                </p:column>  
                <p:column style=" text-align: right">
                    <h:outputLabel value="#{cc.attrs.bill.cheque}">
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>
                </p:column> 
                <p:column style=" text-align: right">
                    <h:outputLabel value="#{cc.attrs.bill.slip}">
                        <f:convertNumber pattern="#,##0.00" />
                    </h:outputLabel>
                </p:column> 
            </p:summaryRow>
        </p:dataTable>
    </cc:implementation>
</html>
